<template>
  <div class="cation-form">
    <el-form label-position="left" label-width="100px" size="small" :model="form" :rules="rules">
      <el-form-item label="企业名称" prop="company_name">
        <el-input placeholder="请输入企业名称" v-model="form.company_name"></el-input>
      </el-form-item>
      <el-form-item label="法人姓名" prop="user_name">
        <el-input placeholder="请输入法人姓名"  v-model="form.user_name"></el-input>
      </el-form-item>
      <el-form-item label="统一社会信用代码" prop="company_code">
        <el-input placeholder="请输入统一社会信用代码"  v-model="form.company_code"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input placeholder="请输入邮箱"  v-model="form.email"></el-input>
      </el-form-item>
      <el-form-item label="联系方式" prop="phone">
        <el-input placeholder="请输入联系方式"  v-model="form.phone"></el-input>
      </el-form-item>
      <el-form-item label="认证理由" prop="reason">
        <el-input placeholder="请输入认证理由" type="textarea"  v-model="form.reason" maxlength="200" show-word-limit :autosize="{ minRows: 6, maxRows: 6}"></el-input>
      </el-form-item>
      <el-form-item label="营业执照" prop="company_license">
        <up-load @change="uploadSuccess($event,4)"></up-load>
      </el-form-item>
      <el-form-item label="法人身份证正面" prop="card_up">
        <up-load @change="uploadSuccess($event,1)"></up-load>
      </el-form-item>
      <el-form-item label="法人身份证反面" prop="card_down">
        <up-load @change="uploadSuccess($event,2)"></up-load>
      </el-form-item>
      <el-form-item label="法人手持身份证" prop="card_person">
        <up-load @change="uploadSuccess($event,3)"></up-load>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import upLoad from '../../../components/unit/upload.vue';

export default {
  components:{ upLoad },
  data(){
    return {
      form : {
        user_name : '',
        email : '',
        phone : '',
        reason : '',
        card_up : '',
        card_down : '',
        card_person:'',
        company_name : '',
        company_code : '',
        company_license : ''
      },
      rules : {
        user_name : [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        email : [{ required: true, message: '请输入邮箱', trigger: 'blur' }],
        phone : [{ required: true, message: '请输入联系方式', trigger: 'blur' }],
        reason : [{ required: true, message: '请输入认证理由', trigger: 'blur' }],
        card_up : [{ required: true, message: '请长传身份证正面照片', trigger: 'blur' }],
        card_down : [{ required: true, message: '请长传身份证反面照片', trigger: 'blur' }],
        card_person : [{ required: true, message: '请长传手持身份证照片', trigger: 'blur' }],
        company_name : [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
        company_code : [{ required: true, message: '请输入统一社会信用代码', trigger: 'blur' }],
        company_license : [{ required: true, message: '请上传营业执照', trigger: 'blur' }],
      }
    }
  },
  methods:{
    uploadSuccess(e,param){
      switch(param){
        case 1:
          this.form.card_up = e;
          break;
        case 2:
          this.form.card_down = e;
          break;
        case 3:
          this.form.card_person = e;
          break;
        case 4:
          this.form.company_license = e;
          break;
      }
    },
  },
  watch:{
    form:{
      handler(v,o){
        this.$emit('change',v);
      },
      deep:true
    }
  }
};
</script>

<style>
.cation-form {
  width: 800px;
  margin-left: 50px;
}
</style>